package xin.petstore.framework.serialnumber.TableSeq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TableSeqService {

    @Autowired
    private TableSeqMapper<TableSeq, String> mapper;

    @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ)
    public int getMaxId(String tabName) {
        int tabMaxId = this.mapper.getTabMaxId(tabName);
        System.out.println("getMaxId=" + tabMaxId);
        this.mapper.increIds(tabName);
        return tabMaxId;
    }
}
